import { storeToRefs } from "pinia";
import useCommon from "@/src/store/common";
import useTopology from "@/src/store/topology";
enum scaleRatioName {
  'topology'= 'scaleRatio',
  'preViewTopology' =  'preViewScaleRatio'
}
export default function useZoomCanvas(keyName: 'topology'|'preViewTopology'){
  const commonStore = useCommon();
  const topologyStore = useTopology();
  const { scaleRatio, preViewScaleRatio } = storeToRefs(commonStore);

  function changeScaleHandle() {
    let curScale =  scaleRatio.value / 100 
    if(keyName === 'topology') {
      commonStore.rulerConfig.maxScaleVal = 5 * curScale
      commonStore.rulerConfig.minSpace = 5 * curScale // 
    }
    topologyStore[keyName]?.scale(curScale);
  }
  return {scaleRatio, preViewScaleRatio, changeScaleHandle}
}